SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.vw_liceniastomadasporlosagentes
AS
SELECT   distinct  l.Dias AS Dias2, a.idAgente AS idagente, a.Documento AS Documento, a.Nombres AS Nombres, c.Expr1 AS Dias, l.Licencia AS Licencias, 
                      l.Dias AS DiasPORlIC
FROM         dbo.tb_Agentes a INNER JOIN
                      dbo.vw_vistaagentesquefaltan c ON a.Documento = c.Documento INNER JOIN
                      dbo.Tb_LicenciasEntreFechasDeTodosLosAgentes2007 l ON l.Documento = c.Documento
WHERE     (l.Dias > 4) and  (Licencia not  IN ('TAREAS PASIVAS ', 'COMISION DE SERVICIO', 'TRASLADO TRANSITORIO','127 Cargo de Mayor Jerarquía','RENUNCIA CONDICIONADA','139 Cargo Político Sin Goce de Haberes','CONVOCATORIA'))
--(Licencia  IN ( 'COMISION DE SERVICIO','CONVOCATORIA','AFECTACIÓN'))													 













GO
